package com.yyy.precision.controller;

import com.yyy.precision.aspect.ApiOperationLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/precision")
@Api("数据精度")
@Slf4j
public class NumberPrecisionController {

    @PostMapping("/doubleCal")
    @ApiOperation("double 计算精度问题")
    @ApiOperationLog(description = "double 计算精度问题")
    public String DoubleCalculate(){
        System.out.println(0.1 + 0.2);
        System.out.println(1.0 - 0.8);
        System.out.println(4.015 * 100);
        System.out.println(123.3 / 100);

        double amount1 = 2.15;
        double amount2 = 1.10;

        if (amount1 - amount2 == 1.05){
            System.out.println("OK");
        }
        return "OK";
    }
}
